home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_tk80.idb / usr / freeware / include / tk / tkMenubutton.h.z / tkMenubutton.h
Encoding:
C/C++ Source or Header  |  1999-04-16  |  7.8 KB  |  216 lines

  1. /*
  2.  * tkMenubutton.h --
  3.  *
  4.  *    Declarations of types and functions used to implement
  5.  *    the menubutton widget.
  6.  *
  7.  * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
  8.  *
  9.  * See the file "license.terms" for information on usage and redistribution
  10.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  11.  *
  12.  * RCS: @(#) $Id: tkMenubutton.h,v 1.4 1998/09/14 18:23:15 stanton Exp $
  13.  */
  14.  
  15. #ifndef _TKMENUBUTTON
  16. #define _TKMENUBUTTON
  17.  
  18. #ifndef _TKINT
  19. #include "tkInt.h"
  20. #endif
  21.  
  22. #ifdef BUILD_tk
  23. # undef TCL_STORAGE_CLASS
  24. # define TCL_STORAGE_CLASS DLLEXPORT
  25. #endif
  26.  
  27. /*
  28.  * A data structure of the following type is kept for each
  29.  * widget managed by this file:
  30.  */
  31.  
  32. typedef struct {
  33.     Tk_Window tkwin;        /* Window that embodies the widget.  NULL
  34.                  * means that the window has been destroyed
  35.                  * but the data structures haven't yet been
  36.                  * cleaned up.*/
  37.     Display *display;        /* Display containing widget.  Needed, among
  38.                  * other things, so that resources can bee
  39.                  * freed up even after tkwin has gone away. */
  40.     Tcl_Interp *interp;        /* Interpreter associated with menubutton. */
  41.     Tcl_Command widgetCmd;    /* Token for menubutton's widget command. */
  42.     char *menuName;        /* Name of menu associated with widget.
  43.                  * Malloc-ed. */
  44.  
  45.     /*
  46.      * Information about what's displayed in the menu button:
  47.      */
  48.  
  49.     char *text;            /* Text to display in button (malloc'ed)
  50.                  * or NULL. */
  51.     int underline;        /* Index of character to underline. */
  52.     char *textVarName;        /* Name of variable (malloc'ed) or NULL.
  53.                  * If non-NULL, button displays the contents
  54.                  * of this variable. */
  55.     Pixmap bitmap;        /* Bitmap to display or None.  If not None
  56.                  * then text and textVar and underline
  57.                  * are ignored. */
  58.     char *imageString;        /* Name of image to display (malloc'ed), or
  59.                  * NULL.  If non-NULL, bitmap, text, and
  60.                  * textVarName are ignored. */
  61.     Tk_Image image;        /* Image to display in window, or NULL if
  62.                  * none. */
  63.  
  64.     /*
  65.      * Information used when displaying widget:
  66.      */
  67.  
  68.     Tk_Uid state;        /* State of button for display purposes:
  69.                  * normal, active, or disabled. */
  70.     Tk_3DBorder normalBorder;    /* Structure used to draw 3-D
  71.                  * border and background when window
  72.                  * isn't active.  NULL means no such
  73.                  * border exists. */
  74.     Tk_3DBorder activeBorder;    /* Structure used to draw 3-D
  75.                  * border and background when window
  76.                  * is active.  NULL means no such
  77.                  * border exists. */
  78.     int borderWidth;        /* Width of border. */
  79.     int relief;            /* 3-d effect: TK_RELIEF_RAISED, etc. */
  80.     int highlightWidth;        /* Width in pixels of highlight to draw
  81.                  * around widget when it has the focus.
  82.                  * <= 0 means don't draw a highlight. */
  83.     XColor *highlightBgColorPtr;
  84.                 /* Color for drawing traversal highlight
  85.                  * area when highlight is off. */
  86.     XColor *highlightColorPtr;    /* Color for drawing traversal highlight. */
  87.     int inset;            /* Total width of all borders, including
  88.                  * traversal highlight and 3-D border.
  89.                  * Indicates how much interior stuff must
  90.                  * be offset from outside edges to leave
  91.                  * room for borders. */
  92.     Tk_Font tkfont;        /* Information about text font, or NULL. */
  93.     XColor *normalFg;        /* Foreground color in normal mode. */
  94.     XColor *activeFg;        /* Foreground color in active mode.  NULL
  95.                  * means use normalFg instead. */
  96.     XColor *disabledFg;        /* Foreground color when disabled.  NULL
  97.                  * means use normalFg with a 50% stipple
  98.                  * instead. */
  99.     GC normalTextGC;        /* GC for drawing text in normal mode. */
  100.     GC activeTextGC;        /* GC for drawing text in active mode (NULL
  101.                  * means use normalTextGC). */
  102.     Pixmap gray;        /* Pixmap for displaying disabled text/icon if
  103.                  * disabledFg is NULL. */
  104.     GC disabledGC;        /* Used to produce disabled effect.  If
  105.                  * disabledFg isn't NULL, this GC is used to
  106.                  * draw button text or icon.  Otherwise
  107.                  * text or icon is drawn with normalGC and
  108.                  * this GC is used to stipple background
  109.                  * across it. */
  110.     int leftBearing;        /* Distance from text origin to leftmost drawn
  111.                  * pixel (positive means to right). */
  112.     int rightBearing;        /* Amount text sticks right from its origin. */
  113.     char *widthString;        /* Value of -width option.  Malloc'ed. */
  114.     char *heightString;        /* Value of -height option.  Malloc'ed. */
  115.     int width, height;        /* If > 0, these specify dimensions to request
  116.                  * for window, in characters for text and in
  117.                  * pixels for bitmaps.  In this case the actual
  118.                  * size of the text string or bitmap is
  119.                  * ignored in computing desired window size. */
  120.     int wrapLength;        /* Line length (in pixels) at which to wrap
  121.                  * onto next line.  <= 0 means don't wrap
  122.                  * except at newlines. */
  123.     int padX, padY;        /* Extra space around text or bitmap (pixels
  124.                  * on each side). */
  125.     Tk_Anchor anchor;        /* Where text/bitmap should be displayed
  126.                  * inside window region. */
  127.     Tk_Justify justify;        /* Justification to use for multi-line text. */
  128.     int textWidth;        /* Width needed to display text as requested,
  129.                  * in pixels. */
  130.     int textHeight;        /* Height needed to display text as requested,
  131.                  * in pixels. */
  132.     Tk_TextLayout textLayout;    /* Saved text layout information. */
  133.     int indicatorOn;        /* Non-zero means display indicator;  0 means
  134.                  * don't display. */
  135.     int indicatorHeight;    /* Height of indicator in pixels.  This same
  136.                  * amount of extra space is also left on each
  137.                  * side of the indicator. 0 if no indicator. */
  138.     int indicatorWidth;        /* Width of indicator in pixels, including
  139.                  * indicatorHeight in padding on each side.
  140.                  * 0 if no indicator. */
  141.  
  142.     /*
  143.      * Miscellaneous information:
  144.      */
  145.  
  146.     Tk_Uid direction;        /* Direction for where to pop the menu.
  147.                      * Valid directions are "above", "below",
  148.                      * "left", "right", and "flush". "flush"
  149.                      * means that the upper left corner of the
  150.                      * menubutton is where the menu pops up.
  151.                      * "above" and "below" will attempt to pop
  152.                      * the menu compleletly above or below
  153.                      * the menu respectively.
  154.                      * "left" and "right" will pop the menu
  155.                      * left or right, and the active item
  156.                      * will be next to the button. */
  157.     Tk_Cursor cursor;        /* Current cursor for window, or None. */
  158.     char *takeFocus;        /* Value of -takefocus option;  not used in
  159.                  * the C code, but used by keyboard traversal
  160.                  * scripts.  Malloc'ed, but may be NULL. */
  161.     int flags;            /* Various flags;  see below for
  162.                  * definitions. */
  163. } TkMenuButton;
  164.  
  165. /*
  166.  * Flag bits for buttons:
  167.  *
  168.  * REDRAW_PENDING:        Non-zero means a DoWhenIdle handler
  169.  *                has already been queued to redraw
  170.  *                this window.
  171.  * POSTED:            Non-zero means that the menu associated
  172.  *                with this button has been posted (typically
  173.  *                because of an active button press).
  174.  * GOT_FOCUS:            Non-zero means this button currently
  175.  *                has the input focus.
  176.  */
  177.  
  178. #define REDRAW_PENDING        1
  179. #define POSTED            2
  180. #define GOT_FOCUS        4
  181.  
  182. /*
  183.  * The following constants define the dimensions of the cascade indicator,
  184.  * which is displayed if the "-indicatoron" option is true.  The units for
  185.  * these options are 1/10 millimeters.
  186.  */
  187.  
  188. #define INDICATOR_WIDTH        40
  189. #define INDICATOR_HEIGHT    17
  190.  
  191. /*
  192.  * Declaration of variables shared between the files in the button module.
  193.  */
  194.  
  195. extern TkClassProcs tkpMenubuttonClass;
  196.  
  197. /*
  198.  * Declaration of procedures used in the implementation of the button
  199.  * widget. 
  200.  */
  201.  
  202. EXTERN void        TkpComputeMenuButtonGeometry _ANSI_ARGS_((
  203.                 TkMenuButton *mbPtr));
  204. EXTERN TkMenuButton *    TkpCreateMenuButton _ANSI_ARGS_((Tk_Window tkwin));
  205. EXTERN void        TkpDisplayMenuButton _ANSI_ARGS_((
  206.                 ClientData clientData));
  207. EXTERN void         TkpDestroyMenuButton _ANSI_ARGS_((
  208.                 TkMenuButton *mbPtr));
  209. EXTERN void        TkMenuButtonWorldChanged _ANSI_ARGS_((
  210.                 ClientData instanceData));
  211.  
  212. # undef TCL_STORAGE_CLASS
  213. # define TCL_STORAGE_CLASS DLLIMPORT
  214.  
  215. #endif /* _TKMENUBUTTON */
  216.